﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QUANLIBANHANG.ENTITY;
using System.Data;
namespace QUANLIBANHANG.DAL
{
    public class ChitiethdDAL
    {
       
        public static void insertChitietHD(ChitiethdEntity cthd)
        {
            try
            {
                ConnectionSQL.commandSQL("INSERT INTO CTHD (SOHD, MASP, SOLUONG) VALUES ('" + cthd.Sohd + "','" + cthd.Masp + "','" + cthd.Soluong + "')");
            }
            catch ( Exception ex)
            {
                
                throw ex;
            }

        }
        // Hàm lấy ra danh sách top sản phẩm
        public static DataTable getTopSP()
        {
            try
            {
                return ConnectionSQL.getTable("SELECT TOP 10 CTHD.MASP, CTHD.SOLUONG, SANPHAM.TENSP, SANPHAM.HINHANH"
                                                + " FROM CTHD JOIN SANPHAM  ON SANPHAM.MASP=CTHD.MASP ORDER BY CTHD.SOLUONG DESC");
            }
            catch (Exception e)
            {
                
                throw e;
            }
        }
    }
}
